
#include <stdio.h>
#include <stdbool.h>
#include <math.h>

#include "pub.h"
#include "leetcode.h"

// 0633
bool judgeSquareSum(int c)
{

    int lo = 0;
    int hi = (int)sqrt(c * 1.0);
    int res;

    while (lo <= hi)
    {
        res = c - hi * hi - lo * lo;
        if (res > 0)
        {
            lo++;
        }
        else if (res < 0)
        {
            hi--;
        }
        else
        {
            return true;
        }
    }
    return false;
}
